//
// Author: jiangli
// Email: 1316762810@qq.com
//

#include <cmath>
#include <iostream>

void LongRunningTask() {
  double number = 5.0;
  double result = std::pow(number, 2);

  std::cout << "长时间运行的任务结果：" << result << std::endl;
}

void LoopBody(int i, int j) {
  double calculation_result = std::sin(i) * std::cos(j);
  std::cout << "在循环体中计算结果：" << calculation_result << std::endl;
}

void ParallelWork() {
  int i, j;
#pragma omp taskgroup
  {
#pragma omp task
    LongRunningTask();  

#pragma omp taskloop private(j) grainsize(500) nogroup
    for (i = 0; i < 10000; i++) {  
      for (j = 0; j < i; j++) {
        LoopBody(i, j);
      }
    }
  }
}

int main() {
  ParallelWork();
  return 0;
}
